<%-- 
    Document   : login
    Created on : Apr 17, 2012, 4:09:25 PM
    Author     : rakesh reddy
--%>

<%@page import="java.sql.*"%>
 <%@page import="cs425proj.model.*" %>
 <%@page import="cs425proj.servlets.*" %>
 <%@page import="java.util.*" %>

 <%
        response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
        response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
        response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
        response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
        %>
        <%String name = (String) session.getAttribute("name");%>
        <% if (null == name) { %>
        <html>
            <META HTTP-EQUIV="refresh" CONTENT="5; URL=http://localhost:8084/cs425proj/">
   <body >
        <table align="center">
            <thead>
                <tr>
                     <h1> CS 425 Project </h1>
                </tr>
            </thead>
        </table>
       <table align="center">
            <thead>
                <tr>
                    <th><h3>
                        <br/>
                        You will be directed to home page in 5 sec.<br/>
                        <img src="spin_loader.gif" width="54" height="55" alt="spin_loader"/><br/>
                        If you aren't forwarded to the new page,<a href="http://localhost:8084/cs425proj/"> click here</a>.
                        
                    </h3></th>
                </tr>
            </thead>
        </table>
       
   </body>
</html>
<%    }%>
<% if (name != null) { %>
<!DOCTYPE html>
<html>
   
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
            $(function() {
                initCountry();
                
            });
            
            function initCountry(response) {
                initSelectHierarchy('country','state.jsp','state-wrapper',initState);
            }
            function initState(response) {
                initSelectHierarchy('state','city.jsp','city-wrapper',initCity);
                
            }
            function initCity(response) {
                initSelectHierarchy('city','theater2.jsp','theater-wrapper',function(res){});
                
            }
            
            
            
            function initSelectHierarchy(selectBoxId, jspFile, childWrapperId, successFunc) {
                $('#'+selectBoxId).change(function() {
                    var val = $(this).val();
                    //alert('Country: '+country);
                    $.ajax({
                        method: 'GET',
                        url: jspFile,
                        data: {'count':val},
                        success: function(responseHtml) {
                            //alert(html);
                            $('#'+childWrapperId).html(responseHtml);
                            successFunc.call(responseHtml);
                            //successFunc();
                        },
                        failure: function() {
                            alert('Unable to get data.');
                        }
                    });
                });
            }
        </script>
    </head>
                    
    <body>
       
        <table align="center">
            <thead>
                <tr>
                    <th><h1>CS 425 Project </h1></th>
                </tr>
            </thead>
        </table>
        <table border="1" width="900"  align="center" >
             <tbody>
                <tr>
                    <td width="450"  border="1">     
                        
                        <form action="newTicket.jsp" method="post"> 
                        <table  align="center">
                            <tr><td>
                                     
                                    <table>
                                       
                                        <tr>
                                            <td>
                                                                              
                                    <div id="country-wrapper">
                                    <select name='country' id="country">
                        <option value="none">Location</option>  
                        <%
                   theaterDetail tdobj = new theaterDetail();
                   ArrayList<String> cityList = tdobj.getCityList();
                    for(int j=0;j<cityList.size();j++){
                        String dism =cityList.get(j);
                        %>
                        <option value="<%=dism%>"><%=dism%></option>  
                        <%
                    }
                        %>
                        </select>  
                                    </div>
                                            </td>
                                            <td><div id='state-wrapper'></div>  </td>
                                            <td><div id='city-wrapper'></div></td>
                                        </tr></table>
                        <div id='list-wrapper'></div>
                                </td></tr>
                                <tr><td>  
                                    <div id='list'> 
                                        <p name='list'>
                                        </p>
                                    </div>
                                </td></tr>
                                <tr><td align="center">
                                <input type="submit" name="buy" value="buy" align="right">
                                
                                    
                                    </td></tr>
                                                   
                                
                       </table>
                                                            
                        </form>    
                </td>
                    <td width="450" bgcolor="#efefef" >
                        <table  align="center">
                            <tr>
                                <td>
                                    
                                   <%
                    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
                    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@fourier.cs.iit.edu:1521:orcl","rjairaj","cs425dbo");  
                    Statement stmt = con.createStatement(); 
                   // String name= (String)session.getAttribute("name");
                    String usr=name;
                    ResultSet rs = stmt.executeQuery("Select * from member where username ='"+usr+"' ");
                    while(rs.next()){
                        %>
                        <p><d >Member id    :  </d><d><%=rs.getString(1)%></d></p>
                        <p><d>Member Type  :  </d><d><%=rs.getString(6)%></d></p> 
                        <p><d>Email        :  </d><d><%=rs.getString(7)%></d></p> 
                        <p><d>Phone        :  </d><d><%=rs.getString(8)%></d></p> 
                        <p><d>Total Points :  </d><d><%=rs.getString(9)%></d></p> 
                        <p><d>Points Spent :  </d><d><%=rs.getString(10)%></d></p> 
                        <form method=get action="LogOutServlet">
                            <input type="submit" value="Log Out"></input>
                        </form>
                        <FORM METHOD="LINK" ACTION="editdetail.jsp" >
                            <INPUT TYPE="submit" VALUE="Edit">
                        </FORM>  
                         <FORM METHOD="LINK" ACTION="newdiscussion.jsp" align="center">
                            Please click for creating Discussions<INPUT TYPE="submit" VALUE="create Discussion">
                            </FORM><br/>
                        
                        <%
                    }
                        %> 
                       
                                    
                                </td>
                               
                           </tr>
                           </table>
        </table>
                        
                        <table border="1" width="900"  align="center" >
                            <tr align="center" >
                           <td>

                               <p><h1>Discussion Forum</h1></p>
                               
                                
                                     
 <% disDetail obj = new disDetail();
 ArrayList<String> dislist = obj.getRecentDisscusion();
 for(int k =0 ;k<dislist.size();k++){
   String item[] = dislist.get(k).split(";");
   String tag = "dis"+(k+1); 
  %>  
  <form action="displayDiscusion" method="get">
  <p> <input type="submit" name="<%=tag%>" value="<%=item[0]%>"> 
      
 </input> <%=item[1]%>  </p>           
       
  </form>                
                            <%}%>
          </td> 

       
       


                                    
                                
                            </tr>
                        </table>
            
           
    </body>
     
</html>
<%}%>
